package com.atguigu.gmallsugar.service;

import com.atguigu.gmallsugar.mapper.KwMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Service
public class KwStatsServiceImpl implements KwStatsService{
    @Autowired
    KwMapper mapper;
    @Override
    public Map<String, BigInteger> kw(int date, int limit) {
        HashMap<String, BigInteger> map = new HashMap<>();

        List<Map<String, Object>> mapList = mapper.kw(date, limit);

        for (Map<String, Object> stringObjectMap : mapList) {
            Object key = stringObjectMap.get("keyword");
            Object score = stringObjectMap.get("score");
            map.put(key.toString(),(BigInteger)score);
        }

        return map;
    }
}
